package com.yy.mapper;

import com.github.pagehelper.Page;
import com.yy.dto.OrdersPageQueryDTO;
import com.yy.entity.Orders;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderMapper {

    void insert(Orders order);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    Page<Orders> select(OrdersPageQueryDTO dto);

    @Select("select * from orders where id = #{id}")
    Orders getbyId(Long id);

    @Update("update orders set status = 6 where id = #{id}")
    void cancel(Long id);
}
